//需求：制作显示年月日星期几，并且显示上午（AM）和下午（PM）的十二禁止的时钟

function formatDate() {
    let arr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
    let date = new Date()
    let year = date.getFullYear()
    let month = (date.getMonth() + 1 + '').padStart(2, '0')
    let dayOfMonth = (date.getDate() + '').padStart(2, '0')
    let hour = (date.getHours() + '').padStart(2, '0')
    let minute = (date.getMinutes() + '').padStart(2, '0')
    let second = (date.getSeconds() + '').padStart(2, '0')
    let dayOfweek = date.getDay()
    let a = ''
    if (hour > 12) {
        hour = hour - 12
        a = 'pM'
    } else {
        a = 'AM'
    }
    let str = year + '年' + month + '月' + dayOfMonth + '日' + hour + '时' + minute + '分' + second + '秒' + a + arr[dayOfweek];
    return str


}
let id;
if (id) {
    clearInterval(id)
}
id = setInterval(function () {
    app.innerHTML = formatDate();
}, 1000)